<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>兑换商品库存查看</title>
<%@include file="../collect/meta.jsp"%>
<link rel="stylesheet" href="css/radius.css" type="text/css"></link>
<link rel="stylesheet" href="css/table.css" type="text/css"></link>
<link rel="stylesheet" href="css/btn-bottom.css" type="text/css"></link>
<script type="text/javascript" src="${ctx}/js/returnTop.js"></script>
</head>
<body lang="zh-cn">
	<div class="wrapper">
		<c:import url="/collect/top.jsp"></c:import>
		<div class="main-container" id="main-container">
			<div class="main-container-inner">
				<c:import url="/collect/left.jsp"></c:import>
				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<ul class="breadcrumb">
							<li><i class="icon-home home-icon"></i>兑换商品库存查看</li>
							<li>兑换商品库存查看</li>
						</ul>
						<!-- .breadcrumb -->
					</div>
					<div class="page-content">
						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
								<form action="exchangegood!watchExchangeGoods"
									name="seekoneMember" method="post">
									<div id="btn-bottom">
										<select name="exchangeGood.shopId">
											<option value="0"
												<c:if test="${exchangeGood.shopId =='0'}">selected='selected'</c:if>>全部</option>
												<c:forEach items="${shops}" var="shop">
												<option value="${shop.id}"
													<c:if test="${exchangeGood.shopId == shop.id }">selected='selected'</c:if>>${shop.name}
												</option>
											</c:forEach>
										</select> 
										<input type="submit" class="btn btn-primary radius btn-sm"
											value="搜索" id="oneMemberBtn">
									</div>
								</form>
								<table id="table_bug_report"
									class="table table-striped table-bordered table-hover">
									<tr>
										<th>商品名称</th>
										<th>店铺名称</th>
										<th>需要积分</th>
										<th>库存数量</th>
										<th>开始时间</th>
									</tr>
									<c:forEach items="${exchangeGoods}" var="exchangeGood"
										varStatus="status">
										<tr <c:if test="${status.count%2==0}">bgcolor="#d8e7f0"</c:if>
											<c:if test="${status.count%2!=0}">bgcolor="#ffffff"</c:if>>
											<td>${exchangeGood.goodname }</td>
											<td>${exchangeGood.shop.name}</td>
											<td>${exchangeGood.score}</td>
											<td>${exchangeGood.amount}</td>
											<td>${exchangeGood.createTime}</td>
										</tr>
									</c:forEach>
								</table>
								<input type="hidden" id="currentIndex" value="${index }">
								<input type="hidden" id="lastIndex" value="${page }">
								<div class="row" id="page">
									<ul class="pagination">
										<li><a href="javascript:void(0);" id="firstPage">首页</a></li>
										<li class="prev"><a href="javascript:void(0);"
											id="previousPage"> <i class="icon-double-angle-left"></i>
										</a>
										</li>
										<li><a href="javascript:void(0)">${index }</a></li>
										<li><a href="javascript:void(0);" id="nextPage"> <i
												class="icon-double-angle-right"></i> </a>
										</li>
										<li><a href="javascript:void(0);" id="lastPage">末页</a></li>
										<li><a href="javascript:void(0)">共${page}页</a></li>
									</ul>
								</div>
								<!-- PAGE CONTENT ENDS -->
							</div>
							<!-- /.col -->
						</div>
						<!-- /.row -->
					</div>
					<!-- /.page-content -->
				</div>
				<!-- /.main-content -->
			</div>
			<!-- /.main-container-inner -->
			<a href="#" id="btn-scroll-up"
				class="btn-scroll-up btn btn-sm btn-inverse"
				style="position:fixed;bottom:0;"> <i
				class="icon-double-angle-up icon-only bigger-110"></i> </a>
		</div>
		<!-- /.main-container -->
		<div class="push"></div>
	</div>
	<c:import url="/collect/down.jsp"></c:import>
</body>

<script type="text/javascript">
	$(document).ready(function() {
		//防收回；兑换管理:$兑换商品库存
		$('.goodsexchange > ul').show();
		$('.goodsexchange > ul > li > a').eq(2).css("color", "red");
		
		// 第一页
		$("#firstPage").click(function() {
			watchEnterpriseConsume(1);
		});

		// 上一页
		$("#previousPage").click(function() {
			var index = $("#currentIndex").val();
			watchEnterpriseConsume(parseInt(index) - parseInt(1));
		});

		// 下一页
		$("#nextPage").click(function() {
			var index = $("#currentIndex").val();
			watchEnterpriseConsume(parseInt(index) + parseInt(1));
		});

		// 最末页
		$("#lastPage").click(function() {
			var index = $("#lastIndex").val();
			watchEnterpriseConsume(index);
		});
		
		function watchEnterpriseConsume(index) {
			var url = "exchangegood!watchExchangeGoods?index=" + index;
			url += "&exchangeGood.shopId=" + $("select[name='exchangeGood.shopId']").val();
			
			window.location.href = url;
		}
	});
</script>
</html>
